import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';

class Loading {
  static void show({bool canDismiss = false, String content = 'Loading...'}) {
    SmartDialog.showLoading(
      backDismiss: canDismiss,
      maskColor: Colors.transparent,
      builder: (context) {
        return Container(
          constraints: BoxConstraints(minWidth: 100),
          decoration: BoxDecoration(
            borderRadius: BorderRadius.circular(10),
            color: Colors.black.withOpacity(0.7),
          ),
          padding: EdgeInsets.symmetric(horizontal: 12, vertical: 12.5),
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: [
              Padding(
                padding: EdgeInsets.all(4),
                child: CircularProgressIndicator(
                  strokeWidth: 2,
                  valueColor: AlwaysStoppedAnimation(Colors.white),
                ),
              ),
              Container(
                margin: EdgeInsets.only(top: 10),
                child: Text(
                  content,
                  style: TextStyle(fontSize: 16.5, color: Colors.white),
                ),
              )
            ],
          ),
        );
      },
    );
  }

  static Future<void> dismiss() async {
    return SmartDialog.dismiss(status: SmartStatus.loading);
  }
}
